const App = getApp();

Component({
  pageLifetimes: {
    show(e){
      let td = this.data, page_url = this._getCurrentPageUrl();
      
      td.tabbarList.map((item,index,data)=>{
        if (item.pagePath == page_url){
          this.setData({
            tabbarActiveItem: index
          });
        }

      });
    }
  },
  properties: {
    tabbarList: {
      type: Array,
      value: App.tabbarList
    },

    selectedIconStyle: {
      type: String
    },
    
    selectedItemStyle: {
      type: String
    }
    
  },

  data: {
    tabbarActiveItem: 0
  },

  methods:{

    /*获取当前页面路径*/ 
    _getCurrentPageUrl(){
      var pages = getCurrentPages();    //获取加载的页面
      var currentPage = pages[pages.length - 1];    //获取当前页面的对象
      var url = currentPage.route;   //当前页面url
      return url
    },
    
    /*获取tabbar项*/
    _getTabbarItem(e){
      let page_url = this._getCurrentPageUrl(), 
          page_path = e.currentTarget.dataset.url;

      if (page_path != page_url){
          wx.reLaunch({
            url: '/' + page_path
          });
          
      }
    }
  }
});